package com.fhz.day013;

import android.os.Bundle;

import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;


public class BlankFragment extends Fragment {
    private Button eveSend;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View inflate = inflater.inflate(R.layout.fragment_blank, container, false);

        eveSend = (Button) inflate.findViewById(R.id.eve_send);
        EventBus.getDefault().register(this);

        eveSend.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBus.getDefault().post("哈哈");
            }
        });
        return inflate;
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getStr(String s){
        eveSend.setText(s);
        //
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}